Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yoga-layout

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yoga-layout

An embeddable and performant flexbox layout engine with bindings for multiple languages

  • 2.0.1
  • npm
  • Socket score

Version published
Weekly downloads
391K
decreased by-3.42%
Maintainers
2
Weekly downloads
 
Created

What is yoga-layout?

The yoga-layout npm package is a cross-platform layout engine that implements Flexbox. It is designed to be fast and efficient, making it suitable for use in performance-critical applications. Yoga-layout allows developers to create complex layouts with ease, using a simple and intuitive API.

What are yoga-layout's main functionalities?

Basic Flexbox Layout

This code demonstrates how to create a basic Flexbox layout using yoga-layout. It creates a root node with two child nodes, sets their dimensions, and calculates the layout.

const { Node, Yoga } = require('yoga-layout');

const root = Node.create();
root.setWidth(500);
root.setHeight(500);

const child1 = Node.create();
child1.setWidth(100);
child1.setHeight(100);
root.insertChild(child1, 0);

const child2 = Node.create();
child2.setWidth(100);
child2.setHeight(100);
root.insertChild(child2, 1);

root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);

console.log(root.getComputedLayout());
console.log(child1.getComputedLayout());
console.log(child2.getComputedLayout());

Align Items

This code demonstrates how to align items within a container using yoga-layout. The root node is set to align its children to the center.

const { Node, Yoga } = require('yoga-layout');

const root = Node.create();
root.setWidth(500);
root.setHeight(500);
root.setAlignItems(Yoga.ALIGN_CENTER);

const child = Node.create();
child.setWidth(100);
child.setHeight(100);
root.insertChild(child, 0);

root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);

console.log(root.getComputedLayout());
console.log(child.getComputedLayout());

Justify Content

This code demonstrates how to justify content within a container using yoga-layout. The root node is set to justify its children to the center.

const { Node, Yoga } = require('yoga-layout');

const root = Node.create();
root.setWidth(500);
root.setHeight(500);
root.setJustifyContent(Yoga.JUSTIFY_CENTER);

const child = Node.create();
child.setWidth(100);
child.setHeight(100);
root.insertChild(child, 0);

root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);

console.log(root.getComputedLayout());
console.log(child.getComputedLayout());

Other packages similar to yoga-layout

FAQs

Package last updated on 01 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc